#include "TConverter.h"

TConverter::TConverter()
{

}

QString TConverter::dateToString(QDate value)
{
    if(value.isNull() || !value.isValid())
    {
        return QString::null;
    }
    return value.toString("yyyyMMdd");
}

QDate TConverter::stringToDate(QString value)
{
    return QDate::fromString(value, "yyyyMMdd");
}


QDateTime TConverter::stringToDatetime(QString value)
{
    return QDateTime::fromString(value, "yyyyMMddhhmmss");
}


QString TConverter::datetimeToString(QDateTime value)
{
    if(value.isNull() || !value.isValid())
    {
        return QString::null;
    }
    return value.toString("yyyyMMddhhmmss");
}

QString TConverter::timeToString(QTime value)
{
    if(value.isNull() || !value.isValid())
    {
        return QString::null;
    }
    return value.toString("hhmmss");
}

QTime TConverter::stringToTime(QString value)
{
    return QTime::fromString(value, "hhmmss");
}

QString TConverter::boolToString(bool value)
{
	if(value)
	{
		return "true";
	}
	else
	{
		return "false";
	}
}

bool TConverter::stringToBool(QString value)
{
	if(value=="true" || value=="1")
	{
		return true;
	}
	else
	{
		return false;
	}
}
